#include "login.h"

bool login () {
    FILE* fp;
    fp = fopen("/benpan/qtproj/calc/calc/login.txt","r");
    if (!fp) {
        printf("Open login err\n");
        exit(-1);
    }
    int i = 0;
    char id[20] = {0}, password[20] = {0}, key[20] = {0};
    scanf("%s\n",id);
    
    /* judge valid id */
    /* find key */

    while ((password[i] = getchar()) != '\n') {
        i++;
    }
    if ( strcmp(password,key) == 0 ) {
        printf("Dear %s \nWelcome\n",id);
        return true;
    } else {
        printf("Wrong password\n");
        return false;
    }
}